package com.xuyiwei.mayi.test;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by xuyiwei on 2019/4/13.
 */
public class VolatileNoAtomic extends Thread {
    private static AtomicInteger atomicInteger = new  AtomicInteger(0);
    private static void addCount(){
        for(int i=0;i<100;i++){
            atomicInteger.incrementAndGet();
            System.out.println(atomicInteger.intValue());
        }
    }

    @Override
    public void run() {
        addCount();
    }

    public static void main(String[] args) throws InterruptedException {
        VolatileNoAtomic[] attrs = new VolatileNoAtomic[10];
        for(VolatileNoAtomic att : attrs){
            att = new VolatileNoAtomic();
            att.start();
        }

    }
}
